/*
 * process.h
 *
 *  Created on: Nov 15, 2011
 *      Author: Danny
 */

#ifndef PROCESS_H_
#define PROCESS_H_
#define MAX_REQUESTS 5
#include "processRequest.h"
#include "pcb.h"
#include <stdlib.h>



typedef enum interuptEnum {
	DISK,
	CALCULATOR,
	KEYBOARD,
	VIDEO,
	PRODUCER,
	PRODUCER_FREE,
	CONSUMER,
	CONSUMER_FREE,
	DISK_READY,
	VIDEO_READY,
	TIMER,
	DONE,
	NONE
} sys_cal;

typedef struct processStr {
	int numOfInstruction;
	int requestStart;
	int curInstruction;
	enum interuptEnum curInterupt;
	PCBStr *pcBlock;
	stProcessRequest *pProcessRequest;
} Process;

Process* createNewProcess() {
	Process *p = malloc(sizeof(*p));
	// srand(time(NULL));
	p->numOfInstruction = (rand() % 10000) + 10;
	p->requestStart = rand() % p->numOfInstruction - 10;
	p->curInstruction = 0;

	// int i;
	/*
	for (i = 0; i < MAX_REQUESTS; i++) {
		// create a request and add to array
	}
	*/
	p->pcBlock = createNewPCB();
	return p;
}

void incProcess(Process *process) {
	if (process->curInstruction == process->numOfInstruction) {
		process->curInstruction = 0;
	}
	process->curInstruction++;
}

#endif /* PROCESS_H_ */



